<?php

/**
 * 
 *
 * @version 1.107
 * @package entity
 */
class reservations_m extends MY_Model {

     public $id;
     private $creationDate;
     private $start;
     private $end;
     private $nrNights;
     private $nrPersons;
     private $nrAdults;
     private $nrChildrens;
     private $childAges;
     private $serviceDescription;
     private $status;
     private $sellingUnit;
     private $netUnit;
     private $priceTotal;
     private $netTotal;
     private $marginTotal;
     private $paid;
     private $roomsId;
     private $serviceTypeId;
     private $data;

     function __construct() {
          parent::__construct();
          $this->table = 'reservations';
     }

     private $fields_name = array(
         'ID',
         'creation_date',
         'start',
         'end',
         'nr_nights',
         'nr_persons',
         'nr_adults',
         'nr_childrens',
         'child_ages',
         'service_description',
         'status',
         'selling_unit',
         'net_unit',
         'price_total',
         'net_total',
         'margin_total',
         'paid',
         'rooms_ID',
         'service_type_ID');
     private $property_names = array(
         'id',
         'creationDate',
         'start',
         'end',
         'nrNights',
         'nrPersons',
         'nrAdults',
         'nrChildrens',
         'childAges',
         'serviceDescription',
         'status',
         'sellingUnit',
         'netUnit',
         'priceTotal',
         'netTotal',
         'marginTotal',
         'paid',
         'roomsId',
         'serviceTypeId');

     /**
      * set value for ID 
      *
      * type:BIGINT,size:19,default:null,primary,unique,autoincrement
      *
      * @param mixed $id
      */
     public function setId($id) {
          $this->id = $id;
     }

     /**
      * get value for ID 
      *
      * type:BIGINT,size:19,default:null,primary,unique,autoincrement
      *
      * @return mixed
      */
     public function getId() {
          return $this->id;
     }

     /**
      * set value for creation_date 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @param mixed $creationDate
      */
     public function setCreationDate($creationDate) {
          $this->creationDate = strtotime($creationDate);
     }

     /**
      * get value for creation_date 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getCreationDate() {
          return $this->creationDate;
     }

     /**
      * set value for start 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @param mixed $start
      */
     public function setStart($start) {
          $this->start = strtotime($start);
     }

     /**
      * get value for start 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getStart() {
          return $this->start;
     }

     /**
      * set value for end 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @param mixed $end
      */
     public function setEnd($end) {
          $this->end = strtotime($end);
     }

     /**
      * get value for end 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getEnd() {
          return $this->end;
     }

     /**
      * set value for nr_nights 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @param mixed $nrNights
      */
     public function setNrNights($nrNights) {
          $this->nrNights = (int) $nrNights;
     }

     /**
      * get value for nr_nights 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getNrNights() {
          return $this->nrNights;
     }

     /**
      * set value for nr_persons 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @param mixed $nrPersons
      */
     public function setNrPersons($nrPersons) {
          $this->nrPersons = (int) $nrPersons;
     }

     /**
      * get value for nr_persons 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getNrPersons() {
          return $this->nrPersons;
     }

     /**
      * set value for nr_adults 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @param mixed $nrAdults
      */
     public function setNrAdults($nrAdults) {
          $this->nrAdults = (int) $nrAdults;
     }

     /**
      * get value for nr_adults 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getNrAdults() {
          return $this->nrAdults;
     }

     /**
      * set value for nr_childrens 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @param mixed $nrChildrens
      */
     public function setNrChildrens($nrChildrens) {
          $this->nrChildrens = (int) $nrChildrens;
     }

     /**
      * get value for nr_childrens 
      *
      * type:INT,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getNrChildrens() {
          return $this->nrChildrens;
     }

     /**
      * set value for child_ages 
      *
      * type:TEXT,size:65535,default:null,nullable
      *
      * @param mixed $childAges
      */
     public function setChildAges($childAges) {
          $this->childAges = $childAges;
     }

     /**
      * get value for child_ages 
      *
      * type:TEXT,size:65535,default:null,nullable
      *
      * @return mixed
      */
     public function getChildAges() {
          return $this->childAges;
     }

     /**
      * set value for service_description 
      *
      * type:TEXT,size:65535,default:null,nullable
      *
      * @param mixed $serviceDescription
      */
     public function setServiceDescription($serviceDescription) {
          $this->serviceDescription = $serviceDescription;
     }

     /**
      * get value for service_description 
      *
      * type:TEXT,size:65535,default:null,nullable
      *
      * @return mixed
      */
     public function getServiceDescription() {
          return $this->serviceDescription;
     }

     /**
      * set value for status 
      *
      * type:VARCHAR,size:20,default:null,nullable
      *
      * @param mixed $status
      */
     public function setStatus($status) {
          $this->status = $status;
     }

     /**
      * get value for status 
      *
      * type:VARCHAR,size:20,default:null,nullable
      *
      * @return mixed
      */
     public function getStatus() {
          return $this->status;
     }

     /**
      * set value for selling_unit 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @param mixed $sellingUnit
      */
     public function setSellingUnit($sellingUnit) {
          $this->sellingUnit = $sellingUnit;
     }

     /**
      * get value for selling_unit 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getSellingUnit() {
          return $this->sellingUnit;
     }

     /**
      * set value for net_unit 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @param mixed $netUnit
      */
     public function setNetUnit($netUnit) {
          $this->netUnit = $netUnit;
     }

     /**
      * get value for net_unit 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getNetUnit() {
          return $this->netUnit;
     }

     /**
      * set value for price_total 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @param mixed $priceTotal
      */
     public function setPriceTotal($priceTotal) {
          $this->priceTotal = $priceTotal;
     }

     /**
      * get value for price_total 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getPriceTotal() {
          return $this->priceTotal;
     }

     /**
      * set value for net_total 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @param mixed $netTotal
      */
     public function setNetTotal($netTotal) {
          $this->netTotal = $netTotal;
     }

     /**
      * get value for net_total 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getNetTotal() {
          return $this->netTotal;
     }

     /**
      * set value for margin_total 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @param mixed $marginTotal
      */
     public function setMarginTotal($marginTotal) {
          $this->marginTotal = $marginTotal;
     }

     /**
      * get value for margin_total 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getMarginTotal() {
          return $this->marginTotal;
     }

     /**
      * set value for paid 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @param mixed $paid
      */
     public function setPaid($paid) {
          $this->paid = $paid;
     }

     /**
      * get value for paid 
      *
      * type:DECIMAL,size:10,default:null,nullable
      *
      * @return mixed
      */
     public function getPaid() {
          return $this->paid;
     }

     /**
      * set value for rooms_ID 
      *
      * type:BIGINT,size:19,default:null,primary,index
      *
      * @param mixed $roomsId
      */
     public function setRoomsId($roomsId) {
          $this->roomsId = $roomsId;
     }

     /**
      * get value for rooms_ID 
      *
      * type:BIGINT,size:19,default:null,primary,index
      *
      * @return mixed
      */
     public function getRoomsId() {
          return $this->roomsId;
     }

     /**
      * set value for service_type_ID 
      *
      * type:BIGINT,size:19,default:2,primary,index
      *
      * @param mixed $serviceTypeId
      */
     public function setServiceTypeId($serviceTypeId) {
          $this->serviceTypeId = $serviceTypeId;
     }

     /**
      * get value for service_type_ID 
      *
      * type:BIGINT,size:19,default:2,primary,index
      *
      * @return mixed
      */
     public function getServiceTypeId() {
          return $this->serviceTypeId;
     }

     public function getData() {
          $this->toArray();
          return $this->data;
     }

     private function toArray() {

          $this_obj = $this->object_to_array($this);

          $cnt = count($this->property_names);

          for ($i = 0; $i < $cnt; $i++):
               $this->data[$this->fields_name[$i]] = $this_obj[$this->property_names[$i]];
          endfor;


          return $this->data;
     }

     private function object_to_array($data) {
          if (is_array($data) || is_object($data)) {
               $result = array();
               foreach ($data as $key => $value) {
                    $result[$key] = $this->object_to_array($value);
               }
               return $result;
          }
          return $data;
     }

     public function insert() {

          $data = $this->toArray();
          $this->db->insert($this->table, $this->data);
          return $this->db->insert_id();
     }

}

?>